package com.qiuyuliantu.base.service.impl;

import java.util.ArrayList;
import java.util.List;
import com.qiuyuliantu.common.utils.DateUtils;
import com.qiuyuliantu.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.qiuyuliantu.base.mapper.QiuDiaryEntriesMapper;
import com.qiuyuliantu.base.domain.QiuDiaryEntries;
import com.qiuyuliantu.base.service.IQiuDiaryEntriesService;

/**
 * 日记条目主Service业务层处理
 *
 * @author 晓君
 * @date 2025-03-26
 */
@Service
public class QiuDiaryEntriesServiceImpl implements IQiuDiaryEntriesService
{
    @Autowired
    private QiuDiaryEntriesMapper qiuDiaryEntriesMapper;

    /**
     * 查询日记条目主
     *
     * @param entryId 日记条目主主键
     * @return 日记条目主
     */
    @Override
    public QiuDiaryEntries selectQiuDiaryEntriesByEntryId(Long entryId)
    {
        return qiuDiaryEntriesMapper.selectQiuDiaryEntriesByEntryId(entryId);
    }

    /**
     * 查询日记条目主列表
     *
     * @param qiuDiaryEntries 日记条目主
     * @return 日记条目主
     */
    @Override
    public List<QiuDiaryEntries> selectQiuDiaryEntriesList(QiuDiaryEntries qiuDiaryEntries)
    {
        qiuDiaryEntries.setUserIdLong(SecurityUtils.getUserId());
        return qiuDiaryEntriesMapper.selectQiuDiaryEntriesList(qiuDiaryEntries);
    }

    /**
     * 新增日记条目主
     *
     * @param qiuDiaryEntries 日记条目主
     * @return 结果
     */
    @Override
    public int insertQiuDiaryEntries(QiuDiaryEntries qiuDiaryEntries)
    {
        qiuDiaryEntries.setCreateTime(DateUtils.getNowDate());
        //获取创建人
        qiuDiaryEntries.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
        return qiuDiaryEntriesMapper.insertQiuDiaryEntries(qiuDiaryEntries);
    }

    /**
     * 修改日记条目主
     *
     * @param qiuDiaryEntries 日记条目主
     * @return 结果
     */
    @Override
    public int updateQiuDiaryEntries(QiuDiaryEntries qiuDiaryEntries)
    {
        qiuDiaryEntries.setUpdateTime(DateUtils.getNowDate());
        qiuDiaryEntries.setUpdateBy(String.valueOf(SecurityUtils.getUserId()));
        return qiuDiaryEntriesMapper.updateQiuDiaryEntries(qiuDiaryEntries);
    }

    /**
     * 批量删除日记条目主
     *
     * @param entryIds 需要删除的日记条目主主键
     * @return 结果
     */
    @Override
    public int deleteQiuDiaryEntriesByEntryIds(Long[] entryIds)
    {
        return qiuDiaryEntriesMapper.deleteQiuDiaryEntriesByEntryIds(entryIds);
    }

    /**
     * 删除日记条目主信息
     *
     * @param entryId 日记条目主主键
     * @return 结果
     */
    @Override
    public int deleteQiuDiaryEntriesByEntryId(Long entryId)
    {
        return qiuDiaryEntriesMapper.deleteQiuDiaryEntriesByEntryId(entryId);
    }
}
